]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/clipboard: Check for errors when creating MetaSelectionSourceMemory
authorYotam Bar-On <tudmotu@gmail.com>
Sun, 28 Jan 2024 17:30:03 +0000 (19:30 +0200)
committerSebastian Wick <sebastian@sebastianwick.net>
Fri, 8 Mar 2024 17:45:25 +0000 (18:45 +0100)
depends on !3551

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3161>

src/st/st-clipboard.c

index 4b730c9930122414ab9ff6b89ca6ebf8612532b2..6df278b2e86ebd3a8c7c055c8ea2889cbacdd9ee 100644 (file)
@@ -297,6 +297,7 @@ st_clipboard_set_content (StClipboard     *clipboard,
 {
   MetaSelectionType selection_type;
   MetaSelectionSource *source;
+  g_autoptr (GError) error = NULL;
 
   g_return_if_fail (ST_IS_CLIPBOARD (clipboard));
   g_return_if_fail (meta_selection != NULL);
@@ -305,7 +306,15 @@ st_clipboard_set_content (StClipboard     *clipboard,
   if (!convert_type (type, &selection_type))
     return;
 
-  source = meta_selection_source_memory_new (mimetype, bytes);
+  source = meta_selection_source_memory_new (mimetype, bytes, &error);
+
+  if (!source)
+    {
+      g_warning ("Failed to create new MetaSelectionSourceMemory: %s",
+                 error->message);
+      return;
+    }
+
   meta_selection_set_owner (meta_selection, selection_type, source);
   g_object_unref (source);
 }